#!/bin/sh 
PATH=/usr/ucb:/usr/bin:/usr/sbin:$PATH
export PATH

###############
# sub routines#
###############
enter_place() {
echo -n "Location:";read WHERE
 
if [ "$WHERE" = "" ]; then
 
   return 
 
else
 
   WHERE=$WHERE"/netscape"
   if [ -x $WHERE ];then
        echo "  Checking $WHERE ..."
        which_version
   else
   echo ""
   echo "ERROR:  File does not exist or is not executable"
   echo ""
   echo "Please re-enter or press return."
   enter_place
   fi
   echo ""
   echo "ERROR:  File not Netscape Navigator version 2.0 or higher"
   echo ""
   echo "Please re-enter or press return."
   enter_place
 
fi
}

end_it() {
echo ""
echo "Hit return to end ..."
read x
exit 0
}

run_it() { 
echo ""
echo "Netscape Navigator version $VERSION.0 or higher starting ..."
echo ""
echo "Running from $WHERE"
$WHERE -geometry =665x770+0+0 file:///tmp/httpd/.products/CDware/index.netscape.html  
end_it
} 

which_version() {
if [ ! -x $WHERE ]; then
   echo ""
   echo "ERROR:  File not present or executable." 
   end_it
else
   VERSION=`$WHERE -version 2>&1 | sed 's/.[^0-9]*//' | sed 's/[^0-9].*//'` 
   if [ "$VERSION" = "2" ]; then 
      run_it
   else
      test="bad"
      return 
   fi
fi
}

##########
#end subs#
##########
echo ""
echo "PLEASE NOTE ....."
echo "*****************"
echo ""
echo "This participant approval version of May Catalyst CDware does "
echo "not contain the Netscape 2.0 or later browser we anticipate using"
echo "as our front end.  THIS IS NOT THE WAY CDware WILL SHIP." 
echo ""
echo "Searching for Netscape Navigator 2.0 or later ..."
echo ""

# CHECK: Netscape lies in path.

WHERE="`which netscape`"

NO=`echo $WHERE | sed 's/[^n].*//g'` 

if [ "$NO" = "n" ]; then
         break	
else
	 which_version 
fi
echo ""
echo "  not in PATH ..."
echo "" 

# CHECK:  Places Netscape could be.

places="$HOME/*etscape*/netscape /opt/*etscape*/netscape /export/*etscape*/netscape /extra/*etscape*/netscape "

for i in $places
do 
   if [ -x $i ];then
	echo "  Checking $i ..."
	WHERE=$i
	which_version
   fi 
done

echo "  Checking /usr/* ..."
for i in `find /usr/*/*etscape*/netscape -print`
do
   if [ -x $i ];then
        echo "  Checking $i ..."
        WHERE=$i
        which_version
   fi
done

# CHECK:  Prompt user for location of Netscape.

echo ""
echo "Unable to find Netscape2.0 or later Navigator in your path and in:"
echo "" 

for i in $places 
do
   echo $i
done

echo ""
echo "Please specify which directory you have a Netscape2.0 or later Navigator."
echo "If you not have a Netscape2.0 or later Navigator installed, please press return."
echo ""
enter_place

enter_place() {
echo -n "Location:";read WHERE 

if [ "$WHERE" != "" ]; then

   continue

else

   WHERE=$WHERE"/netscape"
   if [ -x $WHERE ];then
        echo "  Checking $WHERE ..."
        which_version
   else 
   echo ""
   echo "ERROR:  File does not exist or is not executable"
   echo ""
   enter_place
   fi
   echo ""
   echo "ERROR:  File not Netscape Navigator version 2.0 or higher"
   echo ""
   echo "Please re-enter or press return."
   enter_place 
   
fi
}

echo ""
echo "You can download the latest version of Netscape Navigator at http://www.netscape.com"
echo ""
echo "Please install Netscape Navigator version 2.0 of later, then re-run this"
echo "special participant"

end_it
